﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.OleDb;
//using System.Data.OracleClient;
using Oracle.DataAccess.Client;
using Oracle.DataAccess.Types;

namespace WAContratos.Manager
{
    public class DataBase
    {

        //Returns a DataTable from MS Access database
        public static DataTable GetDataSource(string query)
        {
            return GetDataSource(query, "Nwind.mdb");
        }

        //Returns a DataTable from MS Access database
        public static DataTable GetDataSource(string query, string DataBase)
        {
            OracleConnection conn = new OracleConnection();
            OracleDataAdapter MyOleDbDataAdapter = new OracleDataAdapter();
            DataTable myDataTable = new DataTable();

            conn = Conexion.Cone;
            /*conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" +
                System.Web.HttpContext.Current.Server.MapPath("~/DataBase/" + DataBase);*/

            MyOleDbDataAdapter.SelectCommand = new OracleCommand(query, conn);
            conn.Open();

            try
            { MyOleDbDataAdapter.Fill(myDataTable); }
            finally
            { conn.Close(); }

            return myDataTable;
        }

    }


}
